<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="widget" uri="/widget" %>

<div class="container-fluid center-block pt10">
    <div class="row">
        <div class="col-sm-8 col-lg-8">
            <button type="button" id="addCategoryBtn" class="btn btn-primary"><spring:message code="docrepository.category.action.addCategory" text=""/></button>
        </div>
        <div class="col-sm-4 col-lg-4">
            <form action="" method="post">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="<spring:message code='docrepository.category.search.placeholder' />">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button">Go!</button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    <div class="clearfix"></div>
    <div class="row pt10">
        <div class="col-sm-12 col-lg-12">
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th><spring:message code="docrepository.category.categoryName" text="" /></th>
                            <th><spring:message code="docrepository.category.parent" text="" /></th>
                            <th><spring:message code="docrepository.category.available" text="" /></th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:if test="${empty categoryList}">
                            <tr><td colspan="3"><spring:message code="docrepository.common.nodata" text="" /></td></tr>
                        </c:if>
                        <c:forEach items="${categoryList}" var="category">
                            <tr>
                                <td><c:out value="${category.categoryName}" /></td>
                                <td><c:out value="${category.parent.categoryName}" /></td>
                                <td><c:out value="${category.available}" /></td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                <c:if test="${not empty categoryList}">
                    <ul class="pagination">
                        <li><a href="#">&laquo;</a></li>
                        <li><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li><a href="#">&raquo;</a></li>
                    </ul>
                </c:if>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    (function(){
    	$(document).ready(function(){
    		// 添加目录按钮
    		$('#addCategoryBtn').click(function(){
    			location.href = '<c:url value="/category/edit" />';
    		});
    	});
    })(jQuery);
</script>